﻿namespace MicroCloud.Entity.MySql
{
    /// <summary>
    /// MySql-DbContext迁移模块基类
    /// </summary>
    /// <typeparam name="TDbContext">数据上下文类型</typeparam>
    [Description("MySql-DbContext迁移模块")]
    [DependsOnPacks(typeof(MySqlEntityFrameworkCorePack))]
    public abstract class MySqlDbContextMigrationPackBase<TDbContext> : MigrationPackBase<TDbContext>
        where TDbContext : DbContext, IDbContext
    {
        /// <summary>
        /// 获取 数据库类型
        /// </summary>
        protected override DatabaseType DatabaseType => DatabaseType.MySql;

        /// <summary>
        /// 重写实现获取数据上下文实例
        /// </summary>
        /// <param name="scopedProvider">服务提供者</param>
        /// <returns></returns>
        protected override TDbContext CreateDbContext(IServiceProvider scopedProvider)
        {
            return new DesignTimeDbContextFactory<TDbContext>(scopedProvider).CreateDbContext(Array.Empty<string>());
        }

    }
}